import {defineStore} from 'pinia';
const useCountStore = defineStore({
    id:'count',
    state:()=>({num:1}),
    actions: {
        increment() {
            this.num +=1;
        }
    }
    });

const instance = useCountStore()
instance.$subscribe((_,state)=>{
   localStorage.setItem('count-store',JSON.stringify({...state}))
});
const old = localStorage.getItem('count-store');
if(old){
    instance.$state = JSON.parse(old);
}

export default useCountStore;